var React = require('react');
var token = $.cookie('token');
var mytoken = JSON.parse(token);

import {Button, Checkbox, Icon, Table, Tooltip, notification} from 'antd';

const {Column, ColumnGroup} = Table;
const OperationLogView = React.createClass({
    getInitialState: function () {
        return {logs: []}
    },
    componentWillMount: function () {
        var _this = this;
        $.ajax({
            type: "GET",
            url: "/api/Employee/GetOperationLogs",
            headers: {
                Authorization: "Bearer " + mytoken.access_token
            },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data != null) {
                    _this.setState({logs: data});
                } else {
                    alert("商品信息获取失败");
                }
            },
            error: function (msg) {
                alert(msg);
            }
        });

    },
    render() {
        return (
            <div>
                <section className="content-header">
                    <h1>
                        后台管理
                        <small>角色中心</small>
                    </h1>
                    <ol className="breadcrumb">
                        <li>
                            <a href="#">
                                <i className="fa fa-dashboard"></i>
                                Stage</a>
                        </li>
                        <li>
                            <a href="#">操作日志</a>
                        </li>
                        <li className="active">概览</li>
                    </ol>
                </section>
                <br/>
                <div className="box">
                    <div className="box-header with-border">
                        <h3 className="box-title">操作日志</h3>
                        <div className="box-tools pull-right">
                            <span className="label label-primary">日志查看</span>
                        </div>
                    </div>
                    <div className="box-body">
                        <Table rowKey="RecordId" dataSource={this.state.logs}>
                            <Column title="操作员工编号" dataIndex="EmployeeId" key="EmployeeId"/>
                            <Column title="操作人" dataIndex="Operater" key="Operater"/>
                            <Column title="操作细节" dataIndex="OperatDetail" key="OperatDetail"/>
                            <Column title="操作结果" dataIndex="Result" key="Result" render={(text, record) => (
                                 <Checkbox checked={record.Result}>是否成功</Checkbox>
                            )}/>
                            <Column title="操作时间" dataIndex="OperationTime" key="OperationTime"/>
                        </Table>
                    </div>
                    <div className="box-footer"></div>
                </div>
            </div>
        )
    }
});
module.exports = OperationLogView;